library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ tibble  3.1.0     ✓ purrr   0.3.4
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(arsenal)
library(data.table)
## 
## Attaching package: 'data.table'
## The following object is masked from 'package:purrr':
## 
##     transpose
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
library(expss)
## 
## Use 'expss_output_viewer()' to display tables in the RStudio Viewer.
##  To return to the console output, use 'expss_output_default()'.
## 
## Attaching package: 'expss'
## The following objects are masked from 'package:data.table':
## 
##     copy, like
## The following objects are masked from 'package:stringr':
## 
##     fixed, regex
## The following objects are masked from 'package:purrr':
## 
##     keep, modify, modify_if, transpose, when
## The following objects are masked from 'package:tidyr':
## 
##     contains, nest
## The following objects are masked from 'package:dplyr':
## 
##     between, compute, contains, first, last, na_if, recode, vars
## The following object is masked from 'package:ggplot2':
## 
##     vars
library(ggsci)

#ideas, stratify by what do you consider a good nights sleep
#additive index according to behaviors 
#regression models for the outcome.

#Positive quality of sleep - 
#Consistent wake up 
#Greater than 7 hrs to 9 hrs --> stratify #for sure USE THIS AND ONE OR THE OTHER
  #Agreement questions Q44
  #Current bedtime routines
  #Current lifestyle habits
  #Employment and children
analysisdata <- readRDS("foranalysis.rds")
#Binary variable for seven or nine weighted as 1
analysisdata <- analysisdata %>% mutate(
  sevenornine = case_when(
    Q10_workdayhoursofsleep >= 7.0 & Q10_workdayhoursofsleep <= 9.0 ~ 1,
    Q10_workdayhoursofsleep < 7.0 | Q10_workdayhoursofsleep > 9.0 ~ 0,
    is.na(Q10_workdayhoursofsleep) ~ NA_real_
    ))


#analysisdata <- analysisdata %>% mutate(
#  sevenornine = case_when(
#    Q10_workdayhoursofsleep >= 7.0 & Q10_workdayhoursofsleep <= 9.0 ~ 2,
#    Q10_workdayhoursofsleep < 7.0 | Q10_workdayhoursofsleep > 9.0 ~ 0,
#    is.na(Q10_workdayhoursofsleep) ~ NA_real_
#    ))

#Binary variable for quality of sleep weighted as 1
analysisdata <- analysisdata %>% mutate(
  quality = case_when(
    Q44_6_ifeelpositiveaboutthequalityofmysleep == "Somewhat agree" ~ 1,
    Q44_6_ifeelpositiveaboutthequalityofmysleep == "Strongly agree" ~ 1,
    is.na(Q44_6_ifeelpositiveaboutthequalityofmysleep) ~ NA_real_,
    TRUE ~ 0))

#Binary variable for consistency of wake up weighted as 1
analysisdata <- analysisdata %>% mutate(
  consistency = case_when(
    Q13_consistentwakeup == "Yes" ~ 1,
    is.na(Q13_consistentwakeup) ~ NA_real_,
    TRUE ~ 0))

#Compositescore computation
analysisdata <- analysisdata %>% mutate(
  compositescore = sevenornine + quality + consistency
  )

analysisdata <- analysisdata %>% mutate(compositeoutcomegoodsleep = factor(compositescore, label = c("score 0 - worst sleep", "score 1", "score 2", "score 3 - best sleep"))) %>%
  filter(!is.na(compositescore))

#analysisdata <- analysisdata %>% mutate(compositeoutcomegoodsleep = factor(compositescore, label = c("score 0", "score 1", "score 2", "score 3", "score 4"))) %>%
#  filter(!is.na(compositescore))


# analysisdata <- analysisdata %>% mutate(compositeoutcomegoodsleep = factor(compositescore, label = c("score 0", "score 1", "score 2", "score 3"))) %>%
#  filter(!is.na(compositescore))

#Logistic regression just input demographic variables, then add pyschosocial variables and see how that affects model statistics. Sequential adjustment.

#Cut it in different places. 
#Split between 2 and 3 , and 3 and 4 

#Cumulative score how many ones do you get 
#hours of sleep (7-9) vs. outside of (7-9) --> either interim category 
#quality of sleep (1) sometimes or (0)
#consistent wakeup (1) sometimes/no (0)
tab1 <- tableby(compositeoutcomegoodsleep~ Q3_role + 
                  Q4_gender +
                  Q5_age +
                  Q6_numberinhousehold +
                  Q37_employed +
                  Q8_diagnosis +
                  Q10_workdayhoursofsleep +
                  Q11_weekendhoursofsleep +
                  Q9_howoftensleepy,
                data=analysisdata, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
score 0 - worst sleep (N=27) score 1 (N=64) score 2 (N=54) score 3 - best sleep (N=53) Total (N=198) p value
What is your role at Bloomberg 0.8221
   Faculty/Staff Member 0 (0.0%) 3 (4.7%) 1 (1.9%) 1 (1.9%) 5 (2.5%)
   Full-time student 21 (77.8%) 42 (65.6%) 37 (68.5%) 37 (69.8%) 137 (69.2%)
   Part-time student 6 (22.2%) 19 (29.7%) 16 (29.6%) 15 (28.3%) 56 (28.3%)
What gender do you identify as? 0.0831
   Female 21 (77.8%) 45 (70.3%) 46 (85.2%) 46 (86.8%) 158 (79.8%)
   Male 4 (14.8%) 16 (25.0%) 8 (14.8%) 7 (13.2%) 35 (17.7%)
   Non-binary / third gender 1 (3.7%) 3 (4.7%) 0 (0.0%) 0 (0.0%) 4 (2.0%)
   Prefer not to say 1 (3.7%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 1 (0.5%)
How old are you? 0.8062
   Median (Q1, Q3) 26.50 (25.00, 29.75) 28.00 (25.00, 35.00) 27.50 (25.00, 31.00) 28.00 (24.00, 32.00) 28.00 (25.00, 32.00)
How many people live in your household, including yourself? 0.1012
   Median (Q1, Q3) 2.00 (1.00, 3.00) 2.00 (2.00, 3.00) 2.50 (2.00, 3.00) 2.00 (2.00, 3.00) 2.00 (2.00, 3.00)
Are you currently employed outside of your education program? 0.3231
   N-Miss 0 1 0 0 1
   No 13 (48.1%) 34 (54.0%) 20 (37.0%) 26 (49.1%) 93 (47.2%)
   Yes 14 (51.9%) 29 (46.0%) 34 (63.0%) 27 (50.9%) 104 (52.8%)
Have you ever been diagnosed with any of the following sleep disorders? 0.8841
   Insomnia 3 (11.1%) 4 (6.2%) 4 (7.4%) 1 (1.9%) 12 (6.1%)
   No 24 (88.9%) 57 (89.1%) 48 (88.9%) 50 (94.3%) 179 (90.4%)
   Other 0 (0.0%) 1 (1.6%) 1 (1.9%) 1 (1.9%) 3 (1.5%)
   Sleep Apnea 0 (0.0%) 2 (3.1%) 1 (1.9%) 1 (1.9%) 4 (2.0%)
During the past 5 workdays, how many hours of sleep did you get per night on average? < 0.0012
   Median (Q1, Q3) 6.00 (5.00, 6.00) 6.50 (6.00, 7.00) 7.00 (7.00, 8.00) 7.00 (7.00, 8.00) 7.00 (6.00, 7.50)
During the past weekend, how many hours of sleep did you get per night on average? 0.0672
   Median (Q1, Q3) 7.00 (6.25, 9.00) 7.50 (7.00, 9.00) 8.00 (7.50, 9.00) 8.00 (7.50, 9.00) 8.00 (7.00, 9.00)
How often do you feel sleepy during the day?
   N-Miss 13 30 17 4 64
   Never 0 (0.0%) 0 (0.0%) 2 (5.4%) 0 (0.0%) 2 (1.5%)
   Rarely 1 (7.1%) 6 (17.6%) 6 (16.2%) 12 (24.5%) 25 (18.7%)
   Sometimes 9 (64.3%) 24 (70.6%) 27 (73.0%) 36 (73.5%) 96 (71.6%)
   Very often 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Always 4 (28.6%) 4 (11.8%) 2 (5.4%) 1 (2.0%) 11 (8.2%)
  1. Pearson’s Chi-squared test
  2. Kruskal-Wallis rank sum test
#If student
student <- analysisdata %>% filter(Q3_role != "Faculty/Staff Member")

tab1 <- tableby(compositeoutcomegoodsleep~ Q2_program,
                data=student, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
score 0 - worst sleep (N=27) score 1 (N=61) score 2 (N=53) score 3 - best sleep (N=52) Total (N=193) p value
What is your current program at Bloomberg? 0.1721
   Doctoral Student 4 (14.8%) 14 (23.0%) 18 (34.0%) 16 (30.8%) 52 (26.9%)
   Masters Student 23 (85.2%) 43 (70.5%) 34 (64.2%) 35 (67.3%) 135 (69.9%)
   Other 0 (0.0%) 0 (0.0%) 1 (1.9%) 0 (0.0%) 1 (0.5%)
   Post doctoral student 0 (0.0%) 4 (6.6%) 0 (0.0%) 1 (1.9%) 5 (2.6%)
  1. Pearson’s Chi-squared test
#If employed 
employed <- analysisdata %>% filter(Q37_employed == "Yes")

tab1 <- tableby(compositeoutcomegoodsleep ~ Q38_wfh,
                data=employed, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
score 0 - worst sleep (N=14) score 1 (N=29) score 2 (N=34) score 3 - best sleep (N=27) Total (N=104) p value
Do you work from home? 0.7941
   No 4 (28.6%) 10 (34.5%) 10 (29.4%) 6 (22.2%) 30 (28.8%)
   Yes 10 (71.4%) 19 (65.5%) 24 (70.6%) 21 (77.8%) 74 (71.2%)
  1. Pearson’s Chi-squared test
#If wfh
notworkfromhome <- analysisdata %>% filter(Q37_employed == "Yes" & Q38_wfh == "No")

tab1 <- tableby(compositeoutcomegoodsleep ~ Q39_dayornight,
                data=notworkfromhome, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
score 0 - worst sleep (N=4) score 1 (N=10) score 2 (N=10) score 3 - best sleep (N=6) Total (N=30) p value
Do you work day or night shifts? 0.0351
   N-Miss 0 0 1 0 1
   Day shift 2 (50.0%) 10 (100.0%) 8 (88.9%) 6 (100.0%) 26 (89.7%)
   Night shift 2 (50.0%) 0 (0.0%) 1 (11.1%) 0 (0.0%) 3 (10.3%)
  1. Pearson’s Chi-squared test
tab1 <- tableby(compositeoutcomegoodsleep~  
                  Q15_consistentbedtimeonweekdays +
                  Q49_sleepqualitychangecovid +
                  bedtimeroutine +
                  Q19_howmanyhourssdidyouuseascreen +
                  as.numeric(Q19_howmanyhourssdidyouuseascreen) +
                  Q12_1_howmanynightsusescreen +
                  Q17_stressedaboutschool +
                  cantsleepfeeling +
                  Q18_howoftenpracticemindfullness +
                  behaviors +
                  Q44_1_thingsidointhelasthourbeforesleepaffectthequalityofmysleep +
                  Q44_2_gettingagoodnightssleepisimportantome +
                  Q44_3_mostofmyfriendshaveahealthysleeproutine +
                  Q44_4_lackofsleepaffectsmyacademicperformance +
                  Q44_5_havingaregularsleeproutineimprovesmentalclariy +
                  Q44_7_ithinkcuttingoutscreenuseonehourbeforesleepleadstobettersleep +
                  Q44_8_ithinkingworkingoutregularlyleadstobettersleep +
                  Q44_9_ithinkmeditatingbeforesleephelpsquality +
                  Q59_1_icanmaintainhealthysleephabits +
                  Q59_2_icancutoutscreenuseonehourbeforesleep +
                  Q59_3_icanworkoutregularly +
                  Q59_4_icanmediatebeforebed +
                  Q37_whatdoyouconsideragoodnightssleep +
                  Q50_1_energyfordailyacitivites +
                  Q50_2_attractivness +
                  Q50_3_productivity +
                  Q50_4_accomplishmentofotherdailygoals +
                  Q50_5_mentalandemotionalwellbeing +
                  Q50_6_fosteringmaintaingrelationships +
                  Q50_7_caringforchildren +
                  Q53_1_getoutsidefor10mininthemorning +
                  Q53_2_exerciseduringtheday +
                  Q53_3_doingabreathingexercisebeforesleep +
                  Q53_4_notusescreens +
                  Q53_5_listeningtoacalmingaudiobookorpodcast +
                  information,
                data=analysisdata, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 2. Sleep questions', pfootnote=TRUE, digits = 2)
Table 2. Sleep questions
score 0 - worst sleep (N=27) score 1 (N=64) score 2 (N=54) score 3 - best sleep (N=53) Total (N=198) p value
Do you have a consistent time you wake up on weekdays? < 0.0011
   No 24 (88.9%) 38 (59.4%) 18 (33.3%) 5 (9.4%) 85 (42.9%)
   Sometimes 3 (11.1%) 13 (20.3%) 17 (31.5%) 14 (26.4%) 47 (23.7%)
   Yes 0 (0.0%) 13 (20.3%) 19 (35.2%) 34 (64.2%) 66 (33.3%)
Has your sleep quality changed due to the COVID-19 pandemic? < 0.0011
   N-Miss 0 1 1 0 2
   No 5 (18.5%) 21 (33.3%) 17 (32.1%) 27 (50.9%) 70 (35.7%)
   Yes, I feel my sleep quality has improved 1 (3.7%) 3 (4.8%) 13 (24.5%) 9 (17.0%) 26 (13.3%)
   Yes, I feel my sleep quality has worsened 21 (77.8%) 39 (61.9%) 23 (43.4%) 17 (32.1%) 100 (51.0%)
My bedtime routine includes: 0.7931
   N-Miss 0 1 0 0 1
   Brushing teeth 8 (29.6%) 22 (34.9%) 18 (33.3%) 15 (28.3%) 63 (32.0%)
   Phone usage 1 (3.7%) 4 (6.3%) 3 (5.6%) 1 (1.9%) 9 (4.6%)
   Reading 1 (3.7%) 3 (4.8%) 0 (0.0%) 1 (1.9%) 5 (2.5%)
   Showering 0 (0.0%) 1 (1.6%) 0 (0.0%) 1 (1.9%) 2 (1.0%)
   Washing my face 16 (59.3%) 33 (52.4%) 33 (61.1%) 34 (64.2%) 116 (58.9%)
   Watching TV 1 (3.7%) 0 (0.0%) 0 (0.0%) 1 (1.9%) 2 (1.0%)
How many hours per day do you typically use a screen? (i.e. cell phone, tablet, computer, television)
   N-Miss 2 0 1 0 3
   0 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%)
   1 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%)
   2 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%)
   3 0 (0.0%) 1 (1.6%) 2 (3.8%) 0 (0.0%) 3 (1.5%)
   4 1 (4.0%) 1 (1.6%) 2 (3.8%) 1 (1.9%) 5 (2.6%)
   5 0 (0.0%) 3 (4.7%) 0 (0.0%) 2 (3.8%) 5 (2.6%)
   6 1 (4.0%) 3 (4.7%) 3 (5.7%) 2 (3.8%) 9 (4.6%)
   7 1 (4.0%) 2 (3.1%) 0 (0.0%) 2 (3.8%) 5 (2.6%)
   8 2 (8.0%) 13 (20.3%) 4 (7.5%) 7 (13.2%) 26 (13.3%)
   9 2 (8.0%) 1 (1.6%) 3 (5.7%) 4 (7.5%) 10 (5.1%)
   10 7 (28.0%) 15 (23.4%) 14 (26.4%) 19 (35.8%) 55 (28.2%)
   11 0 (0.0%) 2 (3.1%) 0 (0.0%) 0 (0.0%) 2 (1.0%)
   12 5 (20.0%) 15 (23.4%) 18 (34.0%) 11 (20.8%) 49 (25.1%)
   13 0 (0.0%) 2 (3.1%) 1 (1.9%) 1 (1.9%) 4 (2.1%)
   14 3 (12.0%) 4 (6.2%) 3 (5.7%) 3 (5.7%) 13 (6.7%)
   15 2 (8.0%) 2 (3.1%) 1 (1.9%) 0 (0.0%) 5 (2.6%)
   16 1 (4.0%) 0 (0.0%) 1 (1.9%) 1 (1.9%) 3 (1.5%)
   17 0 (0.0%) 0 (0.0%) 1 (1.9%) 0 (0.0%) 1 (0.5%)
How many hours per day do you typically use a screen? (i.e. cell phone, tablet, computer, television) 0.3772
   Median (Q1, Q3) 11.00 (10.00, 13.00) 11.00 (9.00, 13.00) 11.00 (10.00, 13.00) 11.00 (9.00, 13.00) 11.00 (9.00, 13.00)
In the past week, how many nights did you use screens (i.e. cell phone, tablet, computer, television) within 1 hour before bed? 0.0352
   Median (Q1, Q3) 7.00 (7.00, 7.00) 7.00 (7.00, 7.00) 7.00 (7.00, 7.00) 7.00 (5.00, 7.00) 7.00 (7.00, 7.00)
How stressed do you currently feel about school? 0.0762
   Median (Q1, Q3) 7.00 (7.00, 8.50) 7.00 (5.50, 8.00) 7.00 (6.00, 8.00) 7.00 (4.00, 8.00) 7.00 (5.75, 8.00)
When you can’t sleep do you feel 0.1581
   Angry 1 (3.7%) 2 (3.1%) 5 (9.3%) 3 (5.7%) 11 (5.6%)
   Frustrated 12 (44.4%) 29 (45.3%) 28 (51.9%) 31 (58.5%) 100 (50.5%)
   Guilty 9 (33.3%) 14 (21.9%) 5 (9.3%) 6 (11.3%) 34 (17.2%)
   None of the above 0 (0.0%) 6 (9.4%) 3 (5.6%) 4 (7.5%) 13 (6.6%)
   Other 0 (0.0%) 5 (7.8%) 4 (7.4%) 1 (1.9%) 10 (5.1%)
   Sad 2 (7.4%) 3 (4.7%) 1 (1.9%) 0 (0.0%) 6 (3.0%)
   Stressed 3 (11.1%) 5 (7.8%) 8 (14.8%) 8 (15.1%) 24 (12.1%)
How often do you practice mindfulness techniques? (i.e. breathing exercises, meditation, etc.,)
   N-Miss 2 6 4 6 18
   Never 3 (12.0%) 9 (15.5%) 8 (16.0%) 13 (27.7%) 33 (18.3%)
   Rarely 15 (60.0%) 24 (41.4%) 18 (36.0%) 16 (34.0%) 73 (40.6%)
   Sometimes 7 (28.0%) 24 (41.4%) 22 (44.0%) 17 (36.2%) 70 (38.9%)
   Very often 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Always 0 (0.0%) 1 (1.7%) 2 (4.0%) 1 (2.1%) 4 (2.2%)
Which of the following behaviors do you participate in? 0.3371
   N-Miss 0 1 0 1 2
   Alcohol Consumption 11 (40.7%) 25 (39.7%) 31 (57.4%) 28 (53.8%) 95 (48.5%)
   Cigarette smoking 1 (3.7%) 2 (3.2%) 1 (1.9%) 0 (0.0%) 4 (2.0%)
   Daytime napping 0 (0.0%) 0 (0.0%) 0 (0.0%) 1 (1.9%) 1 (0.5%)
   Drinking Caffeinated beverages 1 (3.7%) 1 (1.6%) 0 (0.0%) 2 (3.8%) 4 (2.0%)
   Exercise 8 (29.6%) 24 (38.1%) 16 (29.6%) 19 (36.5%) 67 (34.2%)
   Social Media Use 6 (22.2%) 11 (17.5%) 6 (11.1%) 2 (3.8%) 25 (12.8%)
The things I do in the last hour before bed affect the quality of my sleep. 0.8401
   Strongly disagree 0 (0.0%) 3 (4.7%) 2 (3.7%) 1 (1.9%) 6 (3.0%)
   Somewhat disagree 2 (7.4%) 3 (4.7%) 4 (7.4%) 4 (7.5%) 13 (6.6%)
   Neither agree nor disagree 2 (7.4%) 8 (12.5%) 5 (9.3%) 3 (5.7%) 18 (9.1%)
   Somewhat agree 10 (37.0%) 32 (50.0%) 24 (44.4%) 28 (52.8%) 94 (47.5%)
   Strongly agree 13 (48.1%) 18 (28.1%) 19 (35.2%) 17 (32.1%) 67 (33.8%)
Getting a good night’s sleep is important to me. 0.0081
   Strongly disagree 0 (0.0%) 0 (0.0%) 1 (1.9%) 0 (0.0%) 1 (0.5%)
   Somewhat disagree 0 (0.0%) 1 (1.6%) 0 (0.0%) 0 (0.0%) 1 (0.5%)
   Neither agree nor disagree 2 (7.4%) 1 (1.6%) 1 (1.9%) 0 (0.0%) 4 (2.0%)
   Somewhat agree 10 (37.0%) 9 (14.1%) 4 (7.4%) 4 (7.5%) 27 (13.6%)
   Strongly agree 15 (55.6%) 53 (82.8%) 48 (88.9%) 49 (92.5%) 165 (83.3%)
Most of my friends have a healthy sleep routine. 0.2391
   N-Miss 0 1 0 0 1
   Strongly disagree 2 (7.4%) 4 (6.3%) 1 (1.9%) 2 (3.8%) 9 (4.6%)
   Somewhat disagree 8 (29.6%) 13 (20.6%) 10 (18.5%) 9 (17.0%) 40 (20.3%)
   Neither agree nor disagree 7 (25.9%) 28 (44.4%) 33 (61.1%) 27 (50.9%) 95 (48.2%)
   Somewhat agree 6 (22.2%) 16 (25.4%) 8 (14.8%) 12 (22.6%) 42 (21.3%)
   Strongly agree 4 (14.8%) 2 (3.2%) 2 (3.7%) 3 (5.7%) 11 (5.6%)
Lack of sleep affects my academic performance. 0.2231
   N-Miss 0 1 0 0 1
   Strongly disagree 1 (3.7%) 0 (0.0%) 1 (1.9%) 1 (1.9%) 3 (1.5%)
   Somewhat disagree 3 (11.1%) 1 (1.6%) 5 (9.3%) 2 (3.8%) 11 (5.6%)
   Neither agree nor disagree 3 (11.1%) 4 (6.3%) 6 (11.1%) 1 (1.9%) 14 (7.1%)
   Somewhat agree 8 (29.6%) 31 (49.2%) 22 (40.7%) 19 (35.8%) 80 (40.6%)
   Strongly agree 12 (44.4%) 27 (42.9%) 20 (37.0%) 30 (56.6%) 89 (45.2%)
Having a regular sleep routine improves mental clarity/sharpness.
   Strongly disagree 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Somewhat disagree 0 (0.0%) 1 (1.6%) 0 (0.0%) 0 (0.0%) 1 (0.5%)
   Neither agree nor disagree 2 (7.4%) 3 (4.7%) 4 (7.4%) 1 (1.9%) 10 (5.1%)
   Somewhat agree 5 (18.5%) 16 (25.0%) 15 (27.8%) 14 (26.4%) 50 (25.3%)
   Strongly agree 20 (74.1%) 44 (68.8%) 35 (64.8%) 38 (71.7%) 137 (69.2%)
I think cutting out screen use 1 hour before bed leads to better sleep. 0.8541
   Strongly disagree 1 (3.7%) 3 (4.7%) 1 (1.9%) 2 (3.8%) 7 (3.5%)
   Somewhat disagree 1 (3.7%) 1 (1.6%) 3 (5.6%) 1 (1.9%) 6 (3.0%)
   Neither agree nor disagree 5 (18.5%) 14 (21.9%) 13 (24.1%) 7 (13.2%) 39 (19.7%)
   Somewhat agree 9 (33.3%) 28 (43.8%) 23 (42.6%) 23 (43.4%) 83 (41.9%)
   Strongly agree 11 (40.7%) 18 (28.1%) 14 (25.9%) 20 (37.7%) 63 (31.8%)
I think working out regularly leads to better sleep.
   Strongly disagree 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Somewhat disagree 1 (3.7%) 1 (1.6%) 1 (1.9%) 0 (0.0%) 3 (1.5%)
   Neither agree nor disagree 1 (3.7%) 7 (10.9%) 6 (11.1%) 3 (5.7%) 17 (8.6%)
   Somewhat agree 6 (22.2%) 23 (35.9%) 20 (37.0%) 8 (15.1%) 57 (28.8%)
   Strongly agree 19 (70.4%) 33 (51.6%) 27 (50.0%) 42 (79.2%) 121 (61.1%)
I think meditating before bed helps sleep quality. 0.2201
   N-Miss 0 0 1 0 1
   Strongly disagree 1 (3.7%) 3 (4.7%) 1 (1.9%) 1 (1.9%) 6 (3.0%)
   Somewhat disagree 1 (3.7%) 4 (6.2%) 3 (5.7%) 3 (5.7%) 11 (5.6%)
   Neither agree nor disagree 7 (25.9%) 23 (35.9%) 17 (32.1%) 19 (35.8%) 66 (33.5%)
   Somewhat agree 5 (18.5%) 24 (37.5%) 22 (41.5%) 14 (26.4%) 65 (33.0%)
   Strongly agree 13 (48.1%) 10 (15.6%) 10 (18.9%) 16 (30.2%) 49 (24.9%)
I can maintain healthy sleep habits. < 0.0011
   N-Miss 0 1 0 0 1
   Not at all confident 7 (25.9%) 5 (7.9%) 2 (3.7%) 0 (0.0%) 14 (7.1%)
   Slightly confident 10 (37.0%) 12 (19.0%) 6 (11.1%) 0 (0.0%) 28 (14.2%)
   Somewhat confident 5 (18.5%) 30 (47.6%) 24 (44.4%) 6 (11.3%) 65 (33.0%)
   Pretty confident 5 (18.5%) 15 (23.8%) 16 (29.6%) 33 (62.3%) 69 (35.0%)
   Extremely confident 0 (0.0%) 1 (1.6%) 6 (11.1%) 14 (26.4%) 21 (10.7%)
I can cut out screen use 1 hour before bed. 0.0211
   N-Miss 0 1 0 0 1
   Not at all confident 6 (22.2%) 13 (20.6%) 16 (29.6%) 9 (17.0%) 44 (22.3%)
   Slightly confident 12 (44.4%) 26 (41.3%) 14 (25.9%) 10 (18.9%) 62 (31.5%)
   Somewhat confident 5 (18.5%) 13 (20.6%) 14 (25.9%) 18 (34.0%) 50 (25.4%)
   Pretty confident 1 (3.7%) 8 (12.7%) 10 (18.5%) 8 (15.1%) 27 (13.7%)
   Extremely confident 3 (11.1%) 3 (4.8%) 0 (0.0%) 8 (15.1%) 14 (7.1%)
I can work out regularly. 0.0401
   N-Miss 1 1 0 0 2
   Not at all confident 5 (19.2%) 7 (11.1%) 2 (3.7%) 1 (1.9%) 15 (7.7%)
   Slightly confident 8 (30.8%) 9 (14.3%) 13 (24.1%) 7 (13.2%) 37 (18.9%)
   Somewhat confident 4 (15.4%) 11 (17.5%) 12 (22.2%) 11 (20.8%) 38 (19.4%)
   Pretty confident 6 (23.1%) 19 (30.2%) 13 (24.1%) 11 (20.8%) 49 (25.0%)
   Extremely confident 3 (11.5%) 17 (27.0%) 14 (25.9%) 23 (43.4%) 57 (29.1%)
I can meditate before bed. 0.7101
   N-Miss 0 1 0 0 1
   Not at all confident 8 (29.6%) 10 (15.9%) 13 (24.1%) 13 (24.5%) 44 (22.3%)
   Slightly confident 7 (25.9%) 20 (31.7%) 13 (24.1%) 11 (20.8%) 51 (25.9%)
   Somewhat confident 5 (18.5%) 21 (33.3%) 12 (22.2%) 16 (30.2%) 54 (27.4%)
   Pretty confident 3 (11.1%) 8 (12.7%) 11 (20.4%) 9 (17.0%) 31 (15.7%)
   Extremely confident 4 (14.8%) 4 (6.3%) 5 (9.3%) 4 (7.5%) 17 (8.6%)
What do you consider a good night’s sleep? 0.2431
   10+ hours 0 (0.0%) 1 (1.6%) 0 (0.0%) 0 (0.0%) 1 (0.5%)
   7 hours 7 (25.9%) 9 (14.1%) 4 (7.4%) 7 (13.2%) 27 (13.6%)
   8 hours 16 (59.3%) 42 (65.6%) 40 (74.1%) 39 (73.6%) 137 (69.2%)
   9 hours 3 (11.1%) 12 (18.8%) 10 (18.5%) 7 (13.2%) 32 (16.2%)
   Less than or equal to 6 hours 1 (3.7%) 0 (0.0%) 0 (0.0%) 0 (0.0%) 1 (0.5%)
Energy for daily activities 0.5482
   Median (Q1, Q3) 5.00 (4.00, 5.00) 5.00 (4.00, 5.00) 5.00 (4.00, 5.00) 5.00 (5.00, 5.00) 5.00 (4.00, 5.00)
Attractiveness (to self & others) 0.5102
   Median (Q1, Q3) 3.00 (3.00, 4.00) 3.00 (2.00, 4.00) 3.00 (2.25, 4.00) 3.00 (2.00, 4.00) 3.00 (2.00, 4.00)
Productivity at work/school 0.5012
   Median (Q1, Q3) 5.00 (5.00, 5.00) 5.00 (4.00, 5.00) 5.00 (4.25, 5.00) 5.00 (4.00, 5.00) 5.00 (4.00, 5.00)
Accomplishment of other daily goals (e.g. exercise, cooking, paying bills, etc) 0.6012
   Median (Q1, Q3) 5.00 (4.00, 5.00) 4.00 (4.00, 5.00) 4.00 (4.00, 5.00) 5.00 (4.00, 5.00) 5.00 (4.00, 5.00)
Mental and emotional wellbeing 0.7782
   Median (Q1, Q3) 5.00 (4.50, 5.00) 5.00 (4.00, 5.00) 5.00 (4.00, 5.00) 5.00 (4.00, 5.00) 5.00 (4.00, 5.00)
Fostering/maintaining relationships 0.3492
   Median (Q1, Q3) 4.00 (4.00, 5.00) 4.00 (3.00, 4.00) 4.00 (3.00, 5.00) 4.00 (3.00, 5.00) 4.00 (3.00, 5.00)
Caring for children 0.9142
   Median (Q1, Q3) 1.00 (1.00, 3.00) 1.00 (1.00, 3.00) 1.00 (1.00, 4.00) 1.00 (1.00, 3.75) 1.00 (1.00, 3.00)
Get outside for 10 minutes in the morning. 0.4242
   Median (Q1, Q3) 4.00 (2.00, 4.00) 4.00 (2.00, 5.00) 4.00 (2.00, 5.00) 4.00 (2.00, 5.00) 4.00 (2.00, 5.00)
Exercise during the day. 0.0122
   Median (Q1, Q3) 4.00 (3.00, 4.00) 4.00 (3.00, 5.00) 4.00 (3.00, 5.00) 5.00 (4.00, 5.00) 4.00 (3.00, 5.00)
Do a breathing exercise before you sleep. 0.6942
   Median (Q1, Q3) 3.00 (2.00, 4.00) 3.00 (2.00, 4.00) 3.00 (2.00, 5.00) 3.00 (2.00, 4.00) 3.00 (2.00, 4.00)
Not use screens (i.e. cell phone, tablet, computer, television) for 1 hour before bed 0.0012
   Median (Q1, Q3) 2.00 (1.00, 2.50) 2.00 (2.00, 3.00) 2.00 (2.00, 3.00) 3.00 (2.00, 4.00) 2.00 (2.00, 3.00)
Listen to a calming audiobook or podcast before bed 0.8882
   Median (Q1, Q3) 3.00 (1.00, 4.50) 3.00 (2.00, 4.00) 3.00 (2.00, 4.00) 2.00 (1.00, 4.00) 3.00 (2.00, 4.00)
Where have you seen or received information about sleep quality or sleep hygiene? 0.0031
   N-Miss 1 6 2 6 15
   Friends 0 (0.0%) 1 (1.7%) 5 (9.6%) 2 (4.3%) 8 (4.4%)
   Health care professional 10 (38.5%) 27 (46.6%) 22 (42.3%) 11 (23.4%) 70 (38.3%)
   News sources 0 (0.0%) 4 (6.9%) 2 (3.8%) 6 (12.8%) 12 (6.6%)
   Other online source 4 (15.4%) 8 (13.8%) 4 (7.7%) 8 (17.0%) 24 (13.1%)
   Social media 5 (19.2%) 15 (25.9%) 18 (34.6%) 17 (36.2%) 55 (30.1%)
   University wellbeing resources 7 (26.9%) 3 (5.2%) 1 (1.9%) 3 (6.4%) 14 (7.7%)
  1. Pearson’s Chi-squared test
  2. Kruskal-Wallis rank sum test

Fig 1

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q3_role, fill=compositeoutcomegoodsleep)) +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Role") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 2

g<- ggplot(student) + 
  geom_bar(aes(x=Q2_program, fill=compositeoutcomegoodsleep)) +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "What is your current program at Bloomberg?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 3

g<- ggplot(student) + 
  geom_bar(aes(x=Q4_gender, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "What gender do you identify as?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 4

g<- ggplot(student) + 
  geom_bar(aes(x=Q37_employed, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Are you currently employed outside of your education program?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 5

g<- ggplot(employed) + 
  geom_bar(aes(x=Q38_wfh, fill=compositeoutcomegoodsleep)) +
  coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Do you work from home?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 6

g<- ggplot(notworkfromhome) + 
  geom_bar(aes(x=Q39_dayornight, fill=compositeoutcomegoodsleep)) +
  coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Do you work day or night shifts?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 7

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q7_children, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=15)) +
  labs(title = "Are there children living in your household?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 8

g<-ggplot(analysisdata) + 
  geom_bar(aes(x=Q8_diagnosis, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=20), axis.text.x = element_text(size=32)) +
  labs(title = "Have you ever been diagnosed with any of the following sleep disorders?") +
  xlab("") + 
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 9

g<-ggplot(analysisdata) + 
  geom_bar(aes(x=Q9_howoftensleepy, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "How often do you feel sleepy during the day?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 10

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q13_consistentwakeup, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Do you have a consistent time you wake up on weekdays?") +
  xlab("") + 
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 11

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q15_consistentbedtimeonweekdays, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Do you have a consistent bedtime on weekdays?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 12

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q49_sleepqualitychangecovid, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Has your sleep quality changed due to the COVID-19 pandemic?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 13

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=bedtimeroutine, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "My bedtime routine includes") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 14

g<-ggplot(analysisdata) + 
  geom_bar(aes(x=Q17_stressedaboutschool, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "How stressed do you currently feel about school?") +
  xlab("") + 
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 2 rows containing non-finite values (stat_count).

Fig 15

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=cantsleepfeeling, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "When you can't sleep do you feel") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 16

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q18_howoftenpracticemindfullness, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "How often do you practice mindfulness techniques? (i.e. breathing exercises, meditation, etc.,") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 17

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=behaviors, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Which of the following behaviors do you participate in? Check all that apply. ") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 18

g<-ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_1_thingsidointhelasthourbeforesleepaffectthequalityofmysleep, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "The things I do in the last hour before bed affect the quality of my sleep.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_2_gettingagoodnightssleepisimportantome, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Getting a good night's sleep is important to me.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_3_mostofmyfriendshaveahealthysleeproutine, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Most of my friends have a healthy sleep routine.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_4_lackofsleepaffectsmyacademicperformance, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Lack of sleep affects my academic performance.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_5_havingaregularsleeproutineimprovesmentalclariy, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Having a regular sleep routine improves mental clarity/sharpness.") +
  xlab("") +
  labs(fill='') 
g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_6_ifeelpositiveaboutthequalityofmysleep, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I feel positive about the quality of my sleep.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_7_ithinkcuttingoutscreenuseonehourbeforesleepleadstobettersleep, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I think cutting out screen use 1 hour before bed leads to better sleep.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<-ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_8_ithinkingworkingoutregularlyleadstobettersleep, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I think working out regularly leads to better sleep.") +
  xlab("") +
  labs(fill='') 
g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_9_ithinkmeditatingbeforesleephelpsquality, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I think meditating before bed helps sleep quality.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 19

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_1_icanmaintainhealthysleephabits, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can maintain healthy sleep habits.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_2_icancutoutscreenuseonehourbeforesleep, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can cut out screen use 1 hour before bed.") +
  xlab("") +
  labs(fill='') 
g+ scale_fill_lancet() 

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_3_icanworkoutregularly, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can work out regularly.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_4_icanmediatebeforebed, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can meditate before bed.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 20

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q50_1_energyfordailyacitivites, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Energy for daily activities") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 1 rows containing non-finite values (stat_count).

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q50_2_attractivness, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Attractiveness (to self & others)") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 1 rows containing non-finite values (stat_count).

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q50_3_productivity, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Productivity at work/school") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 1 rows containing non-finite values (stat_count).

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q50_4_accomplishmentofotherdailygoals, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Accomplishment of other daily goals (e.g. exercise, cooking, paying bills, etc)") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 1 rows containing non-finite values (stat_count).

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q50_5_mentalandemotionalwellbeing, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Mental and emotional wellbeing") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 2 rows containing non-finite values (stat_count).

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q50_6_fosteringmaintaingrelationships, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Fostering/maintaining relationships") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 2 rows containing non-finite values (stat_count).

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q50_7_caringforchildren, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Caring for children") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 8 rows containing non-finite values (stat_count).

Fig 21

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_1_icanmaintainhealthysleephabits, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can maintain healthy sleep habits.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_2_icancutoutscreenuseonehourbeforesleep, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can cut out screen use 1 hour before bed.") +
  xlab("") +
  labs(fill='')  

g+ scale_fill_lancet() 

g<-ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_3_icanworkoutregularly, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can work out regularly.") +
  xlab("") +
  labs(fill='') 

g + scale_fill_lancet() 

g <-ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_4_icanmediatebeforebed, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can meditate before bed.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 22

g<-ggplot(analysisdata) + 
  geom_bar(aes(x=information, fill=compositeoutcomegoodsleep)) +
  theme_test() +
  theme(text = element_text(size=20), axis.text.x = element_text(size=16)) +
  labs(title = "Where have you seen or received information about sleep quality or sleep hygiene? Check all that apply. ") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet()